﻿@using DBMS.Models;

@{
    ViewBag.Title = "Relationships";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Relationships</h2>

@{
    if (ViewBag.Relationships != null)
    {
        if (ViewBag.Relationships.Count > 0)
        {
            <table>
            
            @foreach (Relationship relationship in ViewBag.Relationships)
                {
                    <tr>
                        <td>@relationship.PrimaryTable.Name (@relationship.PrimaryColumn.Name) - @relationship.ForeignTable.Name (@relationship.ForeignColumn.Name)</td>
                        <td>@Html.ActionLink("Delete", "DeleteRelationship", new { databaseId = ViewBag.DatabaseId.ToString(), relId = relationship.Index.ToString() })</td>
                    </tr>
                }
                </table>
        }
        else
        {
            <div>There are no relationships in this database</div>
        }
    }
}